package com.asion.vmovie.ui.MVPModel;

import com.asion.vmovie.api.ApiService;
import com.asion.vmovie.ui.MVPContract.XiLieContract;
import com.asion.vmovie.utils.retrofitCache.SetCacheUtils;

import retrofit2.Retrofit;
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by asion on 16-10-18.
 */

public class XiLieModel implements XiLieContract.Model {
    @Override
    public void getXiLieDatas(int p, int size, XiLieContract.OnGetXiLieData onGetXiLieData) {
        Retrofit retrofit = new Retrofit.Builder().addCallAdapterFactory(RxJavaCallAdapterFactory.create()).addConverterFactory(GsonConverterFactory.create()).client(SetCacheUtils.setCache()).baseUrl(ApiService.BASE_URL).build();
        ApiService apiService = retrofit.create(ApiService.class);
        apiService.getXiLieDatas(p, size).subscribeOn(Schedulers.newThread()).observeOn(AndroidSchedulers.mainThread()).subscribe(seriesBean -> onGetXiLieData.onGetSuccess(seriesBean), throwable -> onGetXiLieData.onGetError(throwable));
    }
}
